<%layout("/common/_layout.html"){ %>
  <%#ajax userTable:{%>
<div class="am-cf am-padding">
  <div class="am-fl am-cf"> <strong class="am-text-primary am-text-lg">系统管理</strong>
    /
    <small>支付方式配置</small>
  </div>
</div>
<%if(so.hasPermission("CCB_PAY_CONFIG")) {%>
<div class="am-g">
  <div class="am-u-sm-12">
    <div class="am-scrollable-horizontal">
      <table class="am-table am-table-hover table-main">
        <thead>
          <tr class="am-text-nowrap">
            <th class="table-title">支付方式</th>
            <th class="table-title">是否开启</th>
          </tr>
        </thead>
        <tbody>
          <tr class="switch-button">
            <td>建行支付</td>
            <td>
              <input data-am-switch data-size="xs" data-off-text="关" data-on-text="开" id="ccb" type="checkbox" value="${ccb.enabled!'1'}" style="display:none;" <%if(ccb.enabled! == 1){%> checked<%}%> />
            </td>
          </tr>
<%}%>
<%if(so.hasPermission("YL_PAY_CONFIG")) {%>
          <tr class="switch-button">
            <td>银联支付</td>
            <td>
              <input data-am-switch data-size="xs" data-off-text="关" data-on-text="开" id="yl" type="checkbox" value="${yl.enabled!'1'}" style="display:none;" <%if(yl.enabled! == 1){%> checked<%}%> />
            </td>
          </tr>
<%}%>
<%if(so.hasPermission("ZFB_PAY_CONFIG")) {%>
          <tr class="switch-button">
            <td>支付宝支付</td>
            <td>
              <input data-am-switch data-size="xs" data-off-text="关" data-on-text="开" id="zfb" type="checkbox" value="${zfb.enabled!'1'}" style="display:none;" <%if(zfb.enabled! == 1){%> checked<%}%> />
            </td>
          </tr>
<%}%>
<%if(so.hasPermission("WECHAT_PAY_CONFIG")) {%>
          <tr class="switch-button">
            <td>微信支付</td>
            <td>
              <input data-am-switch data-size="xs" data-off-text="关" data-on-text="开" id="wechat" type="checkbox" value="${wechat.enabled!'1'}" style="display:none;" <%if(wechat.enabled! == 1){%> checked<%}%> />
            </td>
          </tr>
<%}%>
<%if(so.hasPermission("ABC_PAY_CONFIG")) {%>
          <tr class="switch-button">
            <td>农行支付</td>
            <td>
              <input data-am-switch data-size="xs" data-off-text="关" data-on-text="开" id="abc" type="checkbox" value="${abc.enabled!'1'}" style="display:none;" <%if(abc.enabled! == 1){%> checked<%}%> />
            </td>
          </tr>
<%}%>
<%if(so.hasPermission("CCB_PAY_CONFIG")) {%>
        </tbody>
      </table>
    </div>
  </div>
</div>
<%}%>
<%if(so.hasPermission("OTHER_PAY_CONFIG")) {%>
<div class="am-g">
  <div class="am-u-sm-12">
    <div class="am-scrollable-horizontal">
      <table class="am-table am-table-hover table-main">
        <thead>
          <tr class="am-text-nowrap">
            <th class="table-title">功能</th>
            <th class="table-title">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>充值缴费支付方式</td>
            <td><a href="../website/toConfig?moduleId=1&moduleName=充值缴费">进入授权</a></td>
          </tr>
          <tr>
            <td>选号入网支付方式</td>
            <td><a href="../website/toConfig?moduleId=3&moduleName=选号入网">进入授权</a></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
<%}%>
  
<script type="text/javascript">
  $(function(){
    var $mycheckbox = $('.switch-button').find("input[type='checkbox']");
    $mycheckbox.each(function(){
        var myid = $(this).attr("id");
        console.log("checked id = "+myid);
        $("#"+myid).on({
            "switchChange.bootstrapSwitch": function (event, state) {     
              var params = {state:state,payment:myid};
              $.ajax({
                  type: "post",
                  url: "../website/paymentConfig",
                  data: params,
                  dataType: "json",
                  async:false,
                  success: function(data) {
                    alert(data.message);
                  },
                  error : function(textStatus) {
                    alert("配置错误，请联系管理员");
                  }
              });
          }
        });
    });
  });
</script>
  
<%}%>
<%}%>


